﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web.UI;

namespace CrmControls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:CrmButton1 runat=server></{0}:CrmButton1>")]
    public class CrmButton : System.Web.UI.WebControls.Button
    {
        bool warningConfirm;

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public bool WarningConfirm
        {
            get { return warningConfirm; }
            set { warningConfirm = value; }
        }
        string confirmMessage;

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string ConfirmMessage
        {
            get { return confirmMessage; }
            set { confirmMessage = value; }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (warningConfirm == true)
            {
                this.Attributes.Add("onclick", "return confirm('" + confirmMessage + "');");
            }
            base.Render(writer);
        }
    }
}
